import { getEditorId} from '@/services';
import { IEditorId, IpageItem } from '@/types';
import { formatting } from '@/utils';
import { Effect, Reducer } from 'umi';
export interface EditorModelState {
    editorId: Partial<IEditorId>;
}
export interface EditorModelType {
    namespace: 'editor';
    state: EditorModelState;
    effects: {
        getEditorId: Effect;

    };
    reducers: {
        save: Reducer<EditorModelState>;
    };
}
const EditorModel: EditorModelType = {
    namespace: 'editor',
    state: {
        editorId: {},

    },
    effects: {
        *getEditorId({ payload }, { call, put }) {
            let result = yield call(getEditorId,payload);
            if (result.data) {
                yield put({
                    type: 'save',
                    payload: {
                        editorId:result.data
                    }
                })
            }
        },
    },

    reducers: {
        save(state, action) {
            return {
                ...state,
                ...action.payload,
            };
        },
    },
};

export default EditorModel;


